<?php
include('../../inc/global.inc');
include("../islogin.php");
$url=$_SERVER['HTTP_REFERER'];
?>
<?php
if($_POST[act_tj]){
   $hot_id=$_POST[hot_id]?$_POST[hot_id]:0;
   $hot_istop=$_POST[hot_istop]?$_POST[hot_istop]:0;
   $hot_is_num=$_POST[hot_is_num]?$_POST[hot_is_num]:0;
   $rs=@mysql_query("select * from hot_product where hot_name='$_POST[hot_name]'");
   $row=@mysql_fetch_array($rs);
   if($row['id']){
     echo "<script>alert('已经存在了');location='javascript:history.go(-1)';</script>";
   }else{
     @mysql_query("insert into hot_product  (hot_name,hot_ping,hot_id,hot_istop,hot_is_num,hot_num) values ('$_POST[hot_name]','$_POST[hot_ping]','$hot_id','$hot_istop','$hot_is_num','$_POST[hot_num]')");
	 
     echo "<script>location='".$_POST[url]."';</script>";
   }
}
?>
<?php
if($_POST['act_xg']){
$hot_id=$_POST[hot_id]?$_POST[hot_id]:0;
$hot_istop=$_POST[hot_istop]?$_POST[hot_istop]:0;
$hot_is_num=$_POST[hot_is_num]?$_POST[hot_is_num]:0;
mysql_query("update hot_product  set hot_name='$_POST[hot_name]',hot_ping='$_POST[hot_ping]',hot_id='$hot_id',hot_istop='$hot_istop',hot_is_num='$hot_is_num',hot_num='$_POST[hot_num]' where id='".$_POST['iid']."'");
echo "<script>location='".$_POST[url]."';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
</HEAD>
<BODY>
<center>
  <table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">热点产品目录&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
<?php
if($_GET[tj]){
?>
  <table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
  <form method="post" action="index_modify.php" onSubmit="return check()" name="form1">
    <tr>
      <td height="30" colspan="2" align="center" bgcolor="#8DA8CF">添加热点产品目录</td>
    </tr>
    <tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">产品目录名称</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="hot_name" type="text" id="hot_name" size="30" maxlength="100"></td>
    </tr>
    <tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">首字拼音</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="hot_ping" type="text" id="hot_ping" size="20" maxlength="100"></td>
    </tr>
	 <tr>
      <td height="30" align="center" bgcolor="#FFFFFF">上级目录</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><select name="hot_id">
  <option value="0" selected>--选择上级目录--</option>
  <?php
  $sql="select * from hot_product  where hot_id=0 order by id asc";
  $rs=mysql_query($sql);
  while($row=mysql_fetch_array($rs)){
  ?><option value="<?=$row['id']?>" <?php if($_GET[id]==$row['id']){echo "selected";}?>><?=$row[hot_name]?></option>
  <?php }
  ?>
      </select></td>
    </tr>
	<tr>
     <td height="30" align="center" bgcolor="#FFFFFF">是否已有排名</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;">
	  <select name="hot_istop">
         <option value="0">否</option>
		 <option value="1">是</option>
      </select></td>
    </tr>
	<tr>
     <td height="30" align="center" bgcolor="#FFFFFF">是否限制数量</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;">
	  <select name="hot_is_num">
         <option value="0">否</option>
		 <option value="1">是</option>
      </select>&nbsp;&nbsp;<input name="hot_num" type="text" id="hot_num" value="0" size="10">
      限数字</td>
    </tr>	
    <tr><input type="hidden" name="url" value="<?=$url?>">
	<input type="hidden" name="act_tj" value="ok">
      <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" value="提交"></td>
    </tr>
	</form>
  </table>
  <?php
}
?>
  <?php
if($_GET['xg']){
$sql="select * from hot_product where id=".$_GET['xg_id'];
$rs=mysql_query($sql);
$row=mysql_fetch_array($rs)
?>
<table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <form method="post" action="index_modify.php" onSubmit="return check()" name="form1">
      <tr>
        <td height="30" colspan="2" align="center" bgcolor="#8DA8CF">修改热点产品目录</td>
      </tr>
      <tr>
        <td width="27%" height="30" align="center" bgcolor="#FFFFFF">产品目录名称</td>
        <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="hot_name" type="text" value="<?=$row[hot_name]?>" size="30" maxlength="100"></td>
      </tr>
      <tr>
        <td width="27%" height="30" align="center" bgcolor="#FFFFFF">首字拼音</td>
        <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="hot_ping" type="text" value="<?=$row[hot_ping]?>" size="20" maxlength="100"></td>
      </tr>
      <tr>
        <td height="30" align="center" bgcolor="#FFFFFF">上级目录</td>
        <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;">
		<select name="hot_id">
            <option value="0">--选择上级目录--</option>
  <?php
  $sql2="select * from hot_product where hot_id=0 order by id asc";
  $rs2=mysql_query($sql2);
  while($row2=mysql_fetch_array($rs2)){
  ?>
          <option value="<?=$row2['id']?>" <?php if($row2[id]==$row[hot_id]){echo "selected";}?>><?=$row2[hot_name]?></option>
  <?php
  }
  mysql_free_result($rs2);
  ?>
        </select></td>
      </tr>
	<tr>
     <td height="30" align="center" bgcolor="#FFFFFF">是否已有排名</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;">
	  <select name="hot_istop">
         <option value="0" <?php if($row[hot_istop]==0){echo "selected";}?>>否</option>
		 <option value="1" <?php if($row[hot_istop]==1){echo "selected";}?>>是</option>
      </select></td>
    </tr>
	<tr>
     <td height="30" align="center" bgcolor="#FFFFFF">是否限制数量</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;">
	  <select name="hot_is_num">
         <option value="0" <?php if($row[hot_is_num]==0){echo "selected";}?>>否</option>
		 <option value="1" <?php if($row[hot_is_num]==1){echo "selected";}?>>是</option>
      </select>&nbsp;&nbsp;<input name="hot_num" type="text" id="hot_num" size="10" value="<?=$row[hot_num]?>">限数字</td>
    </tr>
      <tr><input type="hidden" name="url" value="<?=$url?>">
        <input type="hidden" name="act_xg" value="ok"><input type="hidden" name="iid" value="<?=$row['id']?>">
        <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"><input name="submit" type="submit" value="提交"></td>
      </tr>
    </form>
  </table>
  <?php }?>
</center>
</BODY>
</HTML>
